﻿using EMall.Events;

namespace EMall.Domain
{
    public abstract class DomainEvent : Event, IDomainEvent
    {
    }
    public class EntityChangedDomainEvent<TEntity> : DomainEvent where TEntity : class, IEntity
    {
        public TEntity Entity { get; set; }
        public EntityChangedDomainEvent(TEntity entity)
        {
            Entity = entity;
        }
    }
    public class EntityCreatedDomainEvent<TEntity> : EntityChangedDomainEvent<TEntity> where TEntity : class, IEntity
    {
        public EntityCreatedDomainEvent(TEntity entity) : base(entity) { }
    }
    public class EntityUpdatedDomainEvent<TEntity> : EntityChangedDomainEvent<TEntity> where TEntity : class, IEntity
    {
        public string OriginJson { get; set; }
        public EntityUpdatedDomainEvent(string originJson, TEntity entity) : base(entity)
        {
            OriginJson = originJson;
        } 
    }
    public class EntityDeletedDomainEvent<TEntity> : EntityChangedDomainEvent<TEntity> where TEntity : class, IEntity
    {
        public EntityDeletedDomainEvent(TEntity entity) : base(entity) { }
    }
}
